package com.nhc.database.dbmodel;

import com.astrob.model.GeoHash;
import com.astrob.model.LonLat;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Index;


@Entity
public class MeasurePoint {

    @Id(autoincrement = true)
    private Long id;
    private double longitude = 0;//经度
    private double latitude = 0;//纬度
    private double altitude = 0;//海拔高度
    private long datetime = 0; //时间
    private Long measure_id = 0L;//

    private String note = "";//备用 json

    @Index
    private String geohash = "";
    

    @Generated(hash = 878361328)
    public MeasurePoint() {
    }

    public MeasurePoint(LonLat ll, Long measure_id) {
        setLL(ll);
        this.measure_id = measure_id;
        this.datetime = System.currentTimeMillis();
    }

    public MeasurePoint(LonLat ll, double alt) {
        setLL(ll);
        this.altitude = alt;
        this.datetime = System.currentTimeMillis();
    }

    @Generated(hash = 1871845945)
    public MeasurePoint(Long id, double longitude, double latitude, double altitude,
            long datetime, Long measure_id, String note, String geohash) {
        this.id = id;
        this.longitude = longitude;
        this.latitude = latitude;
        this.altitude = altitude;
        this.datetime = datetime;
        this.measure_id = measure_id;
        this.note = note;
        this.geohash = geohash;
    }

    public LonLat getLL() {
        return new LonLat(longitude, latitude);
    }

    public void setLL(LonLat ll) {
        if (ll != null) {
            longitude = ll.GetLon();
            latitude = ll.GetLat();

            GeoHash g = new GeoHash(latitude, longitude);
            g.sethashLength(10);//精确到1米
            this.geohash = g.getGeoHashBase32();
        }
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public double getLongitude() {
        return this.longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    public double getLatitude() {
        return this.latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public double getAltitude() {
        return this.altitude;
    }

    public void setAltitude(double altitude) {
        this.altitude = altitude;
    }

    public long getDatetime() {
        return this.datetime;
    }

    public void setDatetime(long datetime) {
        this.datetime = datetime;
    }

    public Long getMeasure_id() {
        return this.measure_id;
    }

    public void setMeasure_id(Long measure_id) {
        this.measure_id = measure_id;
    }

    public String getGeohash() {
        return this.geohash;
    }

    public void setGeohash(String geohash) {
        this.geohash = geohash;
    }

    public String getNote() {
        return this.note;
    }

    public void setNote(String note) {
        this.note = note;
    }


}
